package edu.msg.jthr.backend.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "USERGROUP")
public class UserGroup extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "USER_ID")
	private User user;
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "ROLE_ID")
	private Role role;
	@Column(name = "USERNAME")
	private String userName;
	@Column(name = "ROLENAME")
	private String roleName;

	public UserGroup() {
	}

	public UserGroup(User user, Role role) {
		this.user = user;
		this.role = role;
		this.userName = user.getUserName();
		this.roleName = role.getRoleName();
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
}
